package com.example.exp_4_javaweb;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/updateStudent")
public class updateStudent extends HttpServlet {
    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        int id = Integer.parseInt(request.getParameter("id"));
        String name = request.getParameter("name");
        String passsword = request.getParameter("password");

        Student student = new Student(id,name,passsword);
        StudentHelper studentHelper = new StudentHelper(student);
        studentHelper.update();

        response.sendRedirect("main.jsp");
    }
}
